﻿status = -1;
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";
var icon = "#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#";
var Star = "#fEffect/CharacterEff/1112904/2/1#";
/***************************************/
var cost = 88888;  //每次消耗的NX
var itemList = Array(
/* 点卷抽 */
Array(3015739, 300, 1, 1),
Array(3015723, 300, 1, 1),
Array(3015712, 300, 1, 1),
Array(3015717, 300, 1, 1),
Array(3015695, 300, 1, 1),
Array(3015694, 300, 1, 1),
Array(3015699, 300, 1, 1),
Array(3015662, 300, 1, 1),
Array(3015661, 300, 1, 1),
Array(3015657, 300, 1, 1),
Array(3015465, 300, 1, 1),
Array(3015600, 300, 1, 1),
Array(3010520, 300, 1, 1),
Array(3010519, 300, 1, 1),
Array(3010621, 300, 1, 1),
Array(3015131, 300, 1, 1),
Array(3015343, 300, 1, 1),
Array(3010788, 300, 1, 1),
Array(3015272, 300, 1, 1),
Array(3015236, 300, 1, 1),
Array(3015263, 300, 1, 1),
Array(3015193, 300, 1, 1),
Array(3015002, 300, 1, 1),
Array(3010936, 300, 1, 1),
Array(3010842, 300, 1, 1),
Array(3010843, 300, 1, 1),
Array(3015131, 300, 1, 1),
Array(3015304, 300, 1, 1),
Array(3016000, 300, 1, 1),
Array(3015111, 300, 1, 1),
Array(3015014, 300, 1, 1),
Array(3010788, 300, 1, 1),
Array(3012032, 500, 1, 1),
Array(3015580, 500, 1, 1),
Array(3015582, 500, 1, 1),
Array(3015583, 500, 1, 1),
Array(3015436, 500, 1, 1),
Array(3015597, 500, 1, 1),
Array(3015599, 500, 1, 1),
Array(3015560, 500, 1, 1),
Array(3015619, 500, 1, 1),
Array(3015620, 500, 1, 1),
Array(3015621, 500, 1, 1),
Array(3015573, 500, 1, 1),
Array(3014014, 500, 1, 1),
Array(3014015, 500, 1, 1),
Array(3014016, 500, 1, 1),
Array(3014017, 500, 1, 1),
Array(3014018, 500, 1, 1),
Array(3015604, 500, 1, 1),
Array(3015605, 500, 1, 1),
Array(3015606, 500, 1, 1),
Array(3015607, 500, 1, 1),
Array(3015608, 500, 1, 1),
Array(3015609, 500, 1, 1),
Array(3015429, 500, 1, 1),
Array(3015350, 500, 1, 1),
Array(3015447, 500, 1, 1),
Array(3015468, 500, 1, 1),
Array(3015448, 500, 1, 1),
Array(3014011, 500, 1, 1),
Array(3015542, 500, 1, 1),
Array(3015543, 500, 1, 1),
Array(3015416, 500, 1, 1),
Array(3015553, 500, 1, 1),
Array(3010609, 500, 1, 1),
Array(3015541, 500, 1, 1),
Array(3012032, 500, 1, 1),
Array(3015526, 500, 1, 1),
Array(3014013, 500, 1, 1),
Array(3015585, 500, 1, 1),
Array(3015584, 500, 1, 1),
Array(3015574, 500, 1, 1),
Array(3015552, 500, 1, 1),
Array(3015551, 500, 1, 1),
Array(3015419, 500, 1, 1),
Array(3015075, 500, 1, 1),
Array(3015426, 500, 1, 1),
Array(3010631, 500, 1, 1),
Array(3010702, 500, 1, 1),
Array(3015243, 500, 1, 1),
Array(3015401, 500, 1, 1),
Array(3015524, 500, 1, 1),
Array(3015338, 500, 1, 1),
Array(3015395, 500, 1, 1),
Array(3015439, 500, 1, 1),
Array(3015383, 500, 1, 1),
Array(3015384, 500, 1, 1),
Array(3014012, 500, 1, 1),
Array(3015462, 500, 1, 1),
Array(3015463, 500, 1, 1),
Array(3015461, 500, 1, 1),
Array(3015382, 500, 1, 1),
Array(3015451, 500, 1, 1),
Array(3015443, 500, 1, 1),
Array(3015228, 500, 1, 1),
Array(3015229, 500, 1, 1),
Array(3015493, 500, 1, 1),
Array(3015494, 500, 1, 1),
Array(3015495, 500, 1, 1),
Array(3015482, 500, 1, 1),
Array(3012031, 500, 1, 1),
Array(3015519, 500, 1, 1),
Array(3013009, 500, 1, 1),
Array(3016101, 500, 1, 1),
Array(3015112, 500, 1, 1),
Array(3012025, 500, 1, 1),
Array(3015029, 500, 1, 1),
Array(3015147, 500, 1, 1),
Array(3015344, 500, 1, 1),
Array(3015338, 500, 1, 1),
Array(3015329, 500, 1, 1),
Array(3015274, 500, 1, 1),
Array(3015316, 500, 1, 1),
Array(3015315, 500, 1, 1),
Array(3015258, 500, 1, 1),
Array(3015312, 500, 1, 1),
Array(3010820, 100, 1, 1)
);

var itemList2 = Array(
Array(3015303, 500, 1, 1),
Array(3015273, 500, 1, 1),
Array(3015270, 500, 1, 1),
Array(3015269, 500, 1, 1),
Array(3015267, 500, 1, 1),
Array(3015265, 500, 1, 1),
Array(3015264, 500, 1, 1),
Array(3015260, 500, 1, 1),
Array(3015259, 500, 1, 1),
Array(3015258, 500, 1, 1),
Array(3015313, 500, 1, 1),
Array(3015234, 500, 1, 1),
Array(3015227, 500, 1, 1),
Array(3015225, 500, 1, 1),
Array(3015211, 500, 1, 1),
Array(3015027, 500, 1, 1),
Array(3015155, 500, 1, 1),
Array(3010415, 500, 1, 1),
Array(3015144, 500, 1, 1),
Array(3015143, 500, 1, 1),
Array(3010578, 500, 1, 1),
Array(3010579, 500, 1, 1),
Array(3015142, 500, 1, 1),
Array(3010590, 500, 1, 1),
Array(3010558, 500, 1, 1),
Array(3015132, 500, 1, 1),
Array(3015133, 500, 1, 1),
Array(3015130, 500, 1, 1),
Array(3015120, 500, 1, 1),
Array(3015129, 500, 1, 1),
Array(3015117, 500, 1, 1),
Array(3015116, 500, 1, 1),
Array(3015115, 500, 1, 1),
Array(3015114, 500, 1, 1),
Array(3015107, 500, 1, 1),
Array(3015112, 500, 1, 1),
Array(3015109, 500, 1, 1),
Array(3010462, 500, 1, 1),
Array(3015099, 500, 1, 1),
Array(3015098, 500, 1, 1),
Array(3015097, 500, 1, 1),
Array(3015096, 500, 1, 1),
Array(3015093, 500, 1, 1),
Array(3015092, 500, 1, 1),
Array(3015091, 500, 1, 1),
Array(3015090, 500, 1, 1),
Array(3015089, 500, 1, 1),
Array(3015088, 500, 1, 1),
Array(3015087, 500, 1, 1),
Array(3015086, 500, 1, 1),
Array(3015085, 500, 1, 1),
Array(3015084, 500, 1, 1),
Array(3015083, 500, 1, 1),
Array(3015083, 500, 1, 1),
Array(3015082, 500, 1, 1),
Array(3015080, 500, 1, 1),
Array(3010603, 500, 1, 1),
Array(3010604, 500, 1, 1),
Array(3010605, 500, 1, 1),
Array(3015076, 500, 1, 1),
Array(3010606, 500, 1, 1),
Array(3015077, 500, 1, 1),
Array(3015078, 500, 1, 1),
Array(3010608, 500, 1, 1),
Array(3015075, 500, 1, 1),
Array(3015064, 500, 1, 1),
Array(3015062, 500, 1, 1),
Array(3015061, 500, 1, 1),
Array(3015006, 500, 1, 1),
Array(3015007, 500, 1, 1),
Array(3015008, 500, 1, 1),
Array(3015009, 500, 1, 1),
Array(3015010, 500, 1, 1),
Array(3015011, 500, 1, 1),
Array(3015012, 500, 1, 1),
Array(3015027, 500, 1, 1),
Array(3015028, 500, 1, 1),
Array(3015030, 500, 1, 1),
Array(3015031, 500, 1, 1),
Array(3015032, 500, 1, 1),
Array(3015033, 500, 1, 1),
Array(3015034, 500, 1, 1),
Array(3015037, 500, 1, 1),
Array(3010370, 500, 1, 1),
Array(3015046, 500, 1, 1),
Array(3015047, 500, 1, 1),
Array(3015048, 500, 1, 1),
Array(3015049, 500, 1, 1),
Array(3015050, 500, 1, 1),
Array(3015053, 500, 1, 1),
Array(3015054, 500, 1, 1),
Array(3015055, 500, 1, 1),
Array(3015056, 500, 1, 1),
Array(3015057, 500, 1, 1),
Array(3015058, 500, 1, 1),
Array(3015059, 500, 1, 1),
Array(3015060, 500, 1, 1),
Array(3010976, 500, 1, 1),
Array(3010983, 500, 1, 1),
Array(3010984, 500, 1, 1),
Array(3010999, 500, 1, 1),
Array(3013002, 500, 1, 1),
Array(3013007, 500, 1, 1),
Array(3013008, 500, 1, 1),
Array(3015000, 500, 1, 1),
Array(3010370, 500, 1, 1),
Array(3010376, 500, 1, 1),
Array(3010377, 500, 1, 1),
Array(3010689, 500, 1, 1),
Array(3010935, 500, 1, 1),
Array(3010543, 500, 1, 1),
Array(3010561, 500, 1, 1),
Array(3010946, 500, 1, 1),
Array(3010947, 500, 1, 1),
Array(3010948, 500, 1, 1),
Array(3010955, 500, 1, 1),
Array(3010835, 500, 1, 1),
Array(3010836, 500, 1, 1),
Array(3010838, 500, 1, 1),
Array(3010849, 500, 1, 1),
Array(3010850, 500, 1, 1),
Array(3010863, 500, 1, 1),
Array(3010865, 500, 1, 1),
Array(3010877, 500, 1, 1),
Array(3010878, 500, 1, 1),
Array(3010894, 500, 1, 1),
Array(3010566, 500, 1, 1),
Array(3010405, 500, 1, 1),
Array(3010742, 500, 1, 1),
Array(3010743, 500, 1, 1),
Array(3010744, 500, 1, 1),
Array(3010747, 500, 1, 1),
Array(3010739, 500, 1, 1),
Array(3010757, 500, 1, 1),
Array(3010758, 500, 1, 1),
Array(3010759, 500, 1, 1),
Array(3010752, 500, 1, 1),
Array(3010754, 500, 1, 1),
Array(3010751, 500, 1, 1),
Array(3010750, 500, 1, 1),
Array(3010755, 500, 1, 1),
Array(3010753, 500, 1, 1),
Array(3010756, 500, 1, 1),
Array(3010760, 500, 1, 1),
Array(3010761, 500, 1, 1),
Array(3010766, 500, 1, 1),
Array(3010767, 500, 1, 1),
Array(3010782, 500, 1, 1),
Array(3010781, 500, 1, 1),
Array(3010783, 500, 1, 1),
Array(3010789, 500, 1, 1),
Array(3010794, 500, 1, 1),
Array(3010795, 500, 1, 1),
Array(3010799, 500, 1, 1),
Array(3010797, 500, 1, 1),
Array(3010798, 500, 1, 1),
Array(3010965, 500, 1, 1),
Array(3010966, 500, 1, 1),
Array(3010967, 500, 1, 1),
Array(3010973, 500, 1, 1),
Array(3010821, 500, 1, 1),
Array(3010822, 500, 1, 1),
Array(3010823, 500, 1, 1),
Array(3010800, 500, 1, 1),
Array(3010801, 500, 1, 1),
Array(3010802, 500, 1, 1),
Array(3010803, 500, 1, 1),
Array(3010804, 500, 1, 1),
Array(3010806, 500, 1, 1),
Array(3010810, 500, 1, 1),
Array(3010813, 500, 1, 1),
Array(3010815, 500, 1, 1),
Array(3010811, 500, 1, 1),
Array(3015544, 250, 1, 1) //水晶冰河椅子
);
function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == 1) {
        status++;
    } else {
        if (status == 0) {
            cm.sendOk("不想使用吗？…我的肚子里有各类#b奇特座椅或卷轴、装备、新奇道具#k哦！");
            cm.dispose();
        }
        status--;

    }
    if (status == 0) {
        var txt = Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + "\r\n";
        txt += "#d想抽奖吗？精品道具入谁家？\r\n";
        txt += "限量椅子 绝版椅子 土豪椅子 等酷炫椅子 [ #r还在等待吗#d ]\r\n\r\n#k";
        txt += "#d[ #r#h ##d ] 玩家点卷：#r" + cm.getNX(1) + "　#b[ 88888点卷抽一回 ]\r\n#k";
        txt += "#b#L0#开始抽奖 [ 可抽 #r" + parseInt(cm.getNX(1) / cost) + "#b 次 ]\t\t#r☆奖品图鉴如下☆#l#k\r\n\r\n";
        txt += Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + Star + "\r\n";
        txt += "#i3015785##i3015234##i3015313##i3015755##i3015693##i3015661##i3015795##i3015642##i3015797##i3010779##i3015031##i3015662##i3015224##i3015262##i3015183##i3015623##i3015408##i3015277##i3010845##i3010698#";
        cm.sendSimple(txt);
    } else if (status == 1) {
        if (selection == 0) {
            if (cm.getNX(1) < cost) {
                cm.sendOk("你好像没有" + cost + "点点卷");
                cm.dispose();
                return;
            }
            var chance = Math.floor(Math.random() * 0);
            var finalitem = Array();
			if (chance >250){
				cm.sendOk("很遗憾未中奖");
				cm.dispose();
				return;
			}
        for (var i = 0; i < itemList.length; i++) {
            if (itemList[i][1] >= chance) {
                finalitem.push(itemList[i]);
            }
        }
        for (var i = 0; i < itemList2.length; i++) {
            if (itemList2[i][1] >= chance) {
                finalitem.push(itemList2[i]);
            }
        }
        if (finalitem.length != 0) {
                var item;
                var random = new java.util.Random();
                var finalchance = random.nextInt(finalitem.length);
                var itemId = finalitem[finalchance][0];
                var quantity = finalitem[finalchance][2];
                var notice = finalitem[finalchance][3];
                item = cm.gainGachaponItem(itemId, quantity, "[点卷座椅抽奖宝箱]", notice);
                if (item != -1) {
                    cm.gainNX(-cost);
                    cm.sendOk("你获得了 #b#z" + item + "##k " + quantity + "个。");
                } else {
                    cm.sendOk("请你确认在背包的装备，消耗，其他窗口中是否有一格以上的空间。");
                }
                cm.safeDispose();
            } else {
                cm.sendOk("今天的运气可真差，什么都没有拿到");
				cm.gainNX(-cost);
                cm.safeDispose();
            }
        }
    }
}

